#ifndef USERTIME_H
#define USERTIME_H

#include "soc/rtc.h"
#include "soc/rtc_cntl_reg.h"
#include "deviceinfodef.h"
//#include "time.h"

#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_attr.h"
#include "esp_sleep.h"
#include "nvs_flash.h"
#include "esp_sntp.h"
//#include "protocol_examples_common.h"

typedef struct
{
    uint8_t year;
    uint8_t mon;
    uint8_t day;
    uint8_t date;
    uint8_t hour;
    uint8_t min;
    uint8_t sec;
}time_type;
extern time_type rtc;

typedef struct
{
    uint8_t year;
    uint8_t mon;
    uint8_t day;
    uint8_t date;
    uint8_t hour;
    uint8_t min;
    uint8_t sec;
}ntp_type;
extern ntp_type ntp;

extern time_t now;
extern struct tm timeinfo;

void clock_init(void);
void esp32_settime(time_type *time);
void esp32_gettime(time_type *time);

#endif

